package com.atguigu.java.ai.langchain4j.controller;

import com.atguigu.java.ai.langchain4j.service.Neo4jService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Tag(name = "neo4j图数据库")
@RequestMapping("/neo4j")
@RestController
public class Neo4jController {

    @Autowired
    private Neo4jService neo4jService;

    @Operation(summary = "上传数据")
    @PostMapping("/upload")
    public String uploadFile(@RequestParam("file") MultipartFile file) {
        try {
            neo4jService.importData(file);
            return "文件上传并导入成功";
        } catch (Exception e) {
            e.printStackTrace();
            return "文件上传或导入失败: " + e.getMessage();
        }
    }
}
